Skip to content

Make Zabbix agent argument errors say which fix is needed - #4

Open
MarkLFT wants to merge 1 commit into
mainfrom
zabbix-arg-validation
Open

Make Zabbix agent argument errors say which fix is needed#4
MarkLFT wants to merge 1 commit into
mainfrom
zabbix-arg-validation

Conversation

@MarkLFT

@MarkLFT MarkLFT commented Aug 2, 2026

Copy link
Copy Markdown
Owner

The report

Running the Linux Zabbix agent script from TacticalRMM against the newly onboarded Komune / Hotel site failed with:

ERROR: ZabbixProxy and ZabbixServer are required.

Accurate, but it doesn't say what to do — and it fires for three different causes that need three different fixes.

What actually happens (traced through TRMM's source, not guessed)

  • parse_script_args (scripts/models.py:205) passes an argument through unaltered when the resolved value is falsy — so an undefined variable arrives as the literal {{site.ZabbixProxy}}.
  • get_db_value (tacticalrmm/utils.py:320) returns the custom field's default_value when the site has no saved value — normally empty, which TRMM then substitutes as ''.

So the two cases are distinguishable at the script, and mean opposite things:

What arrives Cause Fix
Empty Field exists but is blank for this site Set it on the site
Literal {{site.X}} Field is not defined at all Create the custom field
No args at all Script's Arguments field not populated Populate it

The observed error was the empty case — the ZabbixProxy / ZabbixServer Site custom fields exist but have no value for the new site.

Change

Each case now reports separately with the exact UI path, including the distinction that {{global.X}} resolves from the Key Store, not Custom Fields — an easy mix-up.

ERROR: ZabbixProxy is empty.
ERROR: ZabbixServer is empty.
       The Site custom field exists but has no value for this agent's site,
       so TacticalRMM substituted an empty string.
       Set it in: Clients -> <client> -> Sites -> <site> -> Edit -> Custom Fields
       Both ZabbixProxy and ZabbixServer must be set on every site you deploy to.
ERROR: TacticalRMM did not substitute ZabbixVersion — it arrived as: {{global.ZabbixVersion}}
       That means no 'ZabbixVersion' entry exists in the Key Store.
       Create it in: Settings -> Global Settings -> Key Store

All four paths (no args, unresolved site field, blank field, unresolved global) were exercised directly; the blank-field case reproduces the reported failure exactly. bash -n and shellcheck clean. No behaviour change for a correctly configured run.

Related trap found while reading that code — not fixed here

If a Site custom field is undefined, get_db_value falls through to attribute lookup and ends up returning the Site object, which stringifies to the site name. So {{site.ZabbixProxy}} would arrive as Hotel — which passes the script's address regex and would silently configure Server=Hotel.

The literal-{{...}} guard added here does not catch that, because TRMM does substitute a value. Options if you want it covered: warn when the address has no dot and is not an IP (risks false positives on short internal hostnames), or resolve it before writing the config. Happy to add either — flagging rather than guessing at the right trade-off.

Running the Linux Zabbix agent script from TacticalRMM against a newly onboarded
site failed with 'ERROR: ZabbixProxy and ZabbixServer are required', which does
not say what to do — and fires for three different causes needing three
different fixes.

Traced through the TacticalRMM source: parse_script_args passes an argument
through unaltered when the resolved value is falsy, and get_db_value falls back
to the custom field's default_value when the site has no saved value. So the
failure modes reach the script differently:

  - empty value      -> the custom field exists but is blank for this site
  - literal {{...}}  -> no custom field / Key Store entry is defined at all
  - no arguments     -> the script's Arguments field was never populated

Each is now reported separately with the exact TacticalRMM UI path to fix it,
including that global variables come from the Key Store rather than Custom
Fields. No behaviour change for a correctly configured run.
@MarkLFT
MarkLFT force-pushed the zabbix-arg-validation branch from aed9635 to 525a1a9 Compare August 2, 2026 05:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant